home *** CD-ROM | disk | FTP | other *** search
- From: pottier@clipper.ens.fr (Francois Pottier)
- Subject: Submission : skim
- Date: Fri, 16 Jul 93 19:37:52 MET DST
-
-
- This an enhancement to the original "skim" program, written by
- Craig Nevill-Manning. This program helps you browse through an
- info-mac digest (such as those posted on comp.sys.mac.digest).
- For each new file submission, it asks you whether you want to
- download the file or not. Then it creates a script named
- "download". Running this script connects automatically to the
- info-mac ftp site (sumex) and does all the job for you.
-
- This allows to you to download programs at night, by typing
- something like :
- /bin/nohup at 0200am download
-
- Attention : this program is designed for UNIX boxes, NOT Macs.]
-
- To the archive maintainer : I have Craig's authorization to publish
- this small hack, so everything's ok.
-
- The C code (skim.c) follows :
-
- /* To compile this program, first modify the #defines. You have to choose the
- local directory to be used and to set your e-mail address.
-
- Then compile with cc -o skim skim.c -lcurses -ltermcap
-
-
- Original skim program by :
-
- Craig Nevill-Manning, e-mail: cgn@waikato.ac.nz
- Department of Computer Science, phone: +64 7 838 4021 (work)
- University of Waikato, +64 7 838 4232 (home)
- Private Bag 3105,
- Hamilton,
- New Zealand.
-
- Enhanced (added automatic script creation) by :
-
- Francois Pottier e-mail: pottier@dmi.ens.fr
- */
-
-
- #define localDirectory "~/Mac/NEW"
- #define siteName "sumex-aim.stanford.edu"
- #define emailAddress "pottier@dmi.ens.fr"
-
- #include <stdio.h>
- #include <curses.h>
-
- FILE *download;
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- int i;
-
- initscr();
- cbreak();
-
-
- download = fopen("download", "w");
- fprintf(download, "%s\n\n%s%s\n%s%s%s\n%s%s\n%s\n",
- "#!/bin/csh -f",
- "cd ", localDirectory,
- "ftp -n ", siteName, " << EOF",
- "user anonymous ", emailAddress,
- "ascii");
-
- for (i = 1; i < argc; i ++)
- skim(argv[i]);
-
- fprintf(download, "EOF\n");
- fclose(download);
-
- (void) chmod ("download", 493); /* octal 755, rwxr-xr-x */
-
- nocbreak();
- endwin();
- }
-
- skim(filename)
- char *filename;
- {
- FILE *f;
- char s[1000], name[1000], nameOnly[1000];
- int ch, line;
-
- f = fopen(filename, "r");
-
- if (f) {
-
-
- while (!feof(f)) {
- do {
- fgets(s, 1000, f);
- } while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
-
- line = 0;
-
- name[0] = 0;
-
-
- clear();
- refresh();
-
- puts(filename);
- while (!feof(f)) {
- if (line ++ < LINES - 4)
- printf("%s", s);
- fgets(s, 1000, f);
- if (strncmp(s, "[Archived as", 12) == 0) {
- strcpy(name, &s[13]);
- break;
- }
- }
-
- printf("%s", s);
-
-
- if (name[0]) {
- printf("Get this? (y/n)");
-
- do
- ch = getchar();
- while (ch != 'y' && ch != 'n' && ch != 'q');
-
- if (ch == 'y') {
- int i;
-
- for (i = strlen(name); i > 0 && name[i] != ';'; i --) ;
- name[i] = 0;
-
- for (i = strlen(name); i > 0 && name[i] != '/'; i--) ;
- strcpy(nameOnly, &name[i+1]);
- name[i] = 0;
-
- fprintf(download, "cd %s\n", name);
- fprintf(download, "get %s\n", nameOnly);
- }
- else if (ch == 'q') {
- fclose(download);
- nocbreak();
- endwin();
- exit(0);
- }
- }
- }
-
- fclose(f);
- }
- }
-
-
-
-
-
-
-